﻿﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<script type="text/javascript">

	/**
	 * 被选中的页面
	 */
	var selectids = "<%=request.getAttribute("selectids")%>";
	/**
	 * 分配参会人员
	 */
	function assignuser(){
		var url = "meetController.do?addUser";
		var selectV = getassignuserListSelections("id");
		url += '&ids='+selectV;
		url += "&meetid="+"${otherid}";
		$.ajax({
			async : false,
			cache : false,
			type : 'post',
			url : url,// 请求的action路径
			error : function() {// 请求失败处理函数
				
			},
			success : function(data) {
				var d = $.parseJSON(data);
				if (d.success) {
					$.messager.show({
						title : '提示消息',
						msg : '分配成功',
						timeout : 2000,
						showType : 'slide'
					});
					selectids = d.obj;
					setSelectedUser();
				}
			}
		});
	}


	/**
	 * 解除判断题
	 */
	function canceluser(){
		var url = "meetController.do?delUser";
		var selectV = getassignjudgeListSelections("id");
		url += '&ids='+selectV;
		url += "&meetid="+"${otherid}";
		$.ajax({
			async : false,
			cache : false,
			type : 'post',
			url : url,// 请求的action路径
			error : function() {// 请求失败处理函数
				
			},
			success : function(data) {
				var d = $.parseJSON(data);
				if (d.success) {
					$.messager.show({
						title : '提示消息',
						msg : '解除成功',
						timeout : 2000,
						showType : 'slide'
					});
					selectids = d.obj;
					setSelectedUser();
				}
			}
		});
	}


	/**
	 * 设置被选择
	 */
	function setSelectedUser(){			
		var ids = [];
		var rows = $('#assignuserList').datagrid("getRows");
		for(var i=0;i<rows.length;i++){
			if(selectids.indexOf(","+rows[i]["id"]+",")>=0)
				$('#assignuserList').datagrid("selectRow",i);
			else 
				$('#assignuserList').datagrid("unselectRow",i);
		}
	}
</script>
<t:datagrid name="assignuserList" checkbox="true"
	actionUrl="userController.do?datagrid&usertype=${usertype}&departid=${departid}" fit="true"
	fitColumns="true" idField="id" queryMode="group" onLoadSuccess="setSelectedUser();">
	<t:dgCol title="编号" field="id" hidden="false"></t:dgCol>
	<t:dgCol title="用户名" sortable="false" field="userName" query="true"
		width="80"></t:dgCol>
	<t:dgCol title="真实姓名" field="realName" query="true" width="50"></t:dgCol>
	<t:dgCol title="身份证" field="identity" query="true" width="120"></t:dgCol>
	<t:dgToolBar title="分配" icon="icon-add" funname="assignuser"></t:dgToolBar>
	<t:dgToolBar title="解除" icon="icon-remove" funname="canceluser"></t:dgToolBar>	
</t:datagrid>
